# This file is part of decent-cpp.
#
# decent-cpp is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# decent-cpp is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License
# for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with decent-cpp.  If not, see <http://www.gnu.org/licenses/>.

cmake_minimum_required(VERSION 2.8)

project(decent-cpp)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra")

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'Debug' as none was specified.")
  set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
  # Set the possible values of build type for cmake-gui
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
endif()

message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")

# Main executable
add_executable(decent-cpp util.cpp crypto.cpp data.cpp ws.cpp http.cpp main.cpp)
target_compile_definitions(decent-cpp PRIVATE
  DECENT_API_VERSION="1.0.0"
  DECENT_CPP_VERSION="decent-srv-cpp"
  DECENT_PORT=31337
  #USE_HTTPS
  #HTTPS_KEY="debug.key"
  #HTTPS_CERT="debug.crt"
  )

# Libs
## GNU Readline
find_package(Readline)
include_directories(${Readline_INCLUDE_DIR})
target_link_libraries(decent-cpp  ${Readline_LIBRARY})

## SQLite3
find_package(SQLite3)
include_directories(${SQLITE3_INCLUDE_DIRS})
target_link_libraries(decent-cpp ${SQLITE3_LIBRARIES})

## eidheim/Simple-Web-Server
add_subdirectory(Simple-Web-Server)
target_link_libraries(decent-cpp simple-web-server)

## eidheim/Simple-WebSocket-Server
add_subdirectory(Simple-WebSocket-Server)
target_link_libraries(decent-cpp simple-websocket-server)

## nlohmann/json
include_directories(json/single_include)

## optional-lite
include_directories(optional-lite/include)

## libsodium
find_package(sodium)
include_directories(${sodium_INCLUDE_DIR})
target_link_libraries(decent-cpp ${sodium_LIBRARY_RELEASE})

## Boost log
#SET(Boost_USE_STATIC_LIBS ON)
#find_package(Boost 1.54 COMPONENTS log REQUIRED)
#include_directories(decent-cpp ${Boost_INCLUDE_DIR})
#target_link_libraries(decent-cpp ${Boost_LIBRARIES})
